"""
e.set() => 设置事件标志的
e.wait() => 等待事件被设置
"""
import time
import threading
# 创建事件对象
e = threading.Event()
def runner(name):
    print(f"{name}已就位")
    e.wait()
    print(f"{name}开始起跑")
if __name__ == '__main__':
    runners = ["小名","小红","小刚"]
    threads = []
    for name in runners:
        t = threading.Thread(target=runner,args=(name,))
        t.start()
        threads.append(t)
    print("裁判准备发令.....")
    time.sleep(2)
    print("砰!起跑信号发出了...")
    e.set() # 发起起跑信号
    for t in threads:
        t.join()
    print("比赛结束")